import {ref} from 'vue'
import { ElForm } from "element-plus";
export const  useAddBanner = (dialog,onClose,onShow,addBannerModel,emit)=>{
  const imageUrl = ref('')
  const ruleFormRef = ref();
  //确定
const confirm = async () =>{
    emit('save',addBannerModel)
    onClose()
}
//显示弹框
const show = (type,row) =>{
    dialog.height = 600
    //显示弹框
    type==='add'?dialog.title = '新增轮播图' : dialog.title = '编辑轮播图';
    onShow();
    // 添加清空表单数据
    // 添加重置表单
    Object.keys(addBannerModel).forEach(key => {
        addBannerModel[key] = ''
    })
    imageUrl.value = ''
     if(type ===  'edit'){
        Object.assign(addBannerModel,row)
        imageUrl.value = row.url
     }
    addBannerModel.type = type
}
  return{
    addBannerModel,
      confirm,
      show,
      imageUrl
  }
}
